home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / KEYIN.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  3KB  |  77 lines

  1.                 page ,132
  2. ;                       KEYIN.COM
  3. ;                  Dan Rollins 2/11/83
  4. ;     Personal Computer Age, Vol 2.8, August 1983, p. 16-21.
  5. ;  This Program places up to 15 parameter characters into the
  6. ;  IBM PC keyboard buffer for the program to read.
  7. ;
  8. ;     Note: does not enter the space before the characters and
  9. ;  does not place the end of text delimiter.
  10. ;  Use `~' (tilde) to enter a CR (0DH).
  11. ;
  12. ;     Example:
  13. ;
  14. ;       KEYIN 1~a:myfile.txt~
  15. ;       BASIC menu
  16. ;
  17. ;     This will run the BASIC program `menu.bas', answer the
  18. ;  first prompt with `1' [enter], and answer the next prompt
  19. ;  with `a:myfile.txt' [enter]
  20. ;
  21. ;       define the labels for the assembler
  22.  
  23. bios_data segment at 40h
  24.         org     1ah
  25.         buf_head label word
  26.  
  27.         org     1ch
  28.         buf_tail label word
  29.  
  30.         org     1eh
  31.         kb_buf  label word
  32. bios_data ends
  33.  
  34.         page
  35. cseg    segment
  36.         assume cs:cseg, ds:nothing, es:bios_data
  37.  
  38. keyin   proc    far
  39.  
  40.         cli                             ;turn interrupts off
  41.         mov     cx,bios_data            ;
  42.         mov     es,cx                   ;use ES as dest. segment
  43.         mov     word ptr es:buf_head, offset kb_buf
  44.         mov     di,offset kb_buf        ;destination => buffer
  45.         mov     si,80h
  46.         mov     cl,[si]
  47.         xor     ch,ch                   ;cx = count of chars
  48.         cmp     cl,16
  49.         jbe     k1
  50.         mov     cl,16                   ;if length > 16 then = 16
  51. k1:
  52.         cmp     cl,1                    ;if length < 2
  53.         jbe     k_exit                  ;   then do nothing;
  54.         dec     cx                      ;adjust for the space
  55.         mov     bx,cx                   ;copy length in words
  56.         add     bx,bx                   ; bx = length in bytes
  57.         add     bx,offset kb_buf        ; bx = value for buf_tail
  58.         inc     si                      ;point past space
  59.         inc     si                      ;    to first character
  60.         mov     ah,0                    ;scan code = 0 (dummy)
  61. k2:
  62.         lodsb                           ;set al=[si++]
  63.         cmp     al,'~'                  ;do we have a tilde?
  64.         jne     k3                      ;use the char if not
  65.         mov     al,0dh                  ;use CR instead if tilde
  66. k3:
  67.         stosw                           ;[di++]=al, [di++]=0
  68.         loop    k2                      ;do for the entire string
  69.  
  70.         mov     es:[buf_tail],bx        ;now indicate the length
  71. k_exit:
  72.         sti                             ;interrupts back on
  73.         int     20h                     ;exit to DOS
  74.  
  75. keyin   endp
  76. cseg    ends
  77.